Public Class CCustomerContact
    Inherits BOBase

    Protected m_State As CustomerContactDS
    Protected m_DA As CustomerContacts

#Region "   Inherits Implementation"
    Sub New()
        m_State = New CustomerContactDS
    End Sub

    Public Overrides ReadOnly Property DA() As DABase
        Get
            If m_DA Is Nothing Then
                m_DA = New CustomerContacts
            End If

            Return m_DA
        End Get
    End Property

    Public Overrides Property ObjectState() As DataSet
        Get
            Return m_State
        End Get
        Set(ByVal Value As DataSet)
            Try
                m_State = CType(Value, CustomerContactDS)
            Catch ex As InvalidCastException
                Throw New ApplicationException("Invalid CUSTOMER_CONTACT Dataset!", ex)
            End Try
        End Set
    End Property

    Public Overrides Sub Init()
        Dim dr As CustomerContactDS.CUSTOMER_CONTACTRow = m_State.CUSTOMER_CONTACT.NewCUSTOMER_CONTACTRow
        With dr
            .CUSTOMER_ID_FK = Nothing
            .CONTACT_NAME = String.Empty
        End With
        m_State.CUSTOMER_CONTACT.Rows.Add(dr)
    End Sub
#End Region

#Region "   Data Properties"
    Protected ReadOnly Property DataRow() As CustomerContactDS.CUSTOMER_CONTACTRow
        Get
            Return CType(Me.Row, CustomerContactDS.CUSTOMER_CONTACTRow)
        End Get
    End Property

    Public ReadOnly Property ID() As System.Int32
        Get
            Return Me.DataRow.CONTACT_ID_PK
        End Get
    End Property

    Public Property CustomerID() As System.Int32
        Get
            Return Me.DataRow.CUSTOMER_ID_FK
        End Get
        Set(ByVal Value As System.Int32)
            Me.DataRow.CUSTOMER_ID_FK = Value
        End Set
    End Property

    Public Property ContactName() As System.String
        Get
            Return Me.DataRow.CONTACT_NAME
        End Get
        Set(ByVal Value As System.String)
            Me.DataRow.CONTACT_NAME = Value
        End Set
    End Property
#End Region

    Public Shared Function GetContactName(ByVal contactId As Integer) As String
        If contactId > 0 Then
            Dim objCC As New CCustomerContact
            Try
                objCC.Load(contactId)
            Catch ex As Exception
                Throw New ApplicationException("Can not load contact name", ex)
            End Try

            Return objCC.ContactName
        Else
            Return Nothing
        End If

    End Function
    Public Shared Function GetCustomerContactList(ByVal cId As Integer) As DataTable
        Dim ds As New DataSet
        ds = DataHelper.ExecuteDataSet2("GetCustomerContactList", cId)
        Return ds.Tables(0)
    End Function
End Class
